package com.xujiang.umengutils;

import android.util.Log;

import com.umeng.message.IUmengRegisterCallback;
import com.umeng.message.PushAgent;

/**
 * Created by xujiang on 2017/4/19.
 */

public class ourUmengUtils {


    public static PushAgent getPushAgent() {
        return pushAgent;
    }

    public static void setPushAgent(PushAgent pushAgent) {
        ourUmengUtils.pushAgent = pushAgent;
    }

    private static PushAgent pushAgent;



    public static void umengRegister() throws Exception {

        if(pushAgent == null){
            throw new Exception("请调用setPushAgent方法初始化pushAgent");
        }

        //注册推送服务，每次调用register方法都会回调该接口
        pushAgent.register(new IUmengRegisterCallback() {
            @Override
            public void onSuccess(String deviceToken) {
                //注册成功会返回device token
                Log.i("mytoken",deviceToken);

            }
            @Override
            public void onFailure(String s, String s1) {
                Log.i("mytoken","is fail:"+s1+"--->"+s);

            }
        });

    }

}
